import request from '../../utils/request'

export interface LockDayDto {
  id: string
  userId: string
  lockDay: number
  useCoin: number
}

/**
 * 分页获取个人车源列表
 * @param {number} page 页数 
 * @param {string} brand  品牌
 */
export const getPersonalChannelPage = async (page: number, brand: string): Promise<PageResult<ListPersonalChannel[]>> => await request(`/api/wxpersonalchannel/page?page=${page}&brand=${brand}`, 'GET') as Promise<PageResult<ListPersonalChannel[]>>

/**
 * 获取个人车源详情
 * @param {string} id 
 */
export const getPersonalChannelDetail = async (id: string) => await request(`/api/wxpersonalchannel?id=${id}`, 'GET') as Promise<Result<ListPersonalChannel>>

/**
 * 锁定车源
 * @param {LockDayDto} data 
 */
export const lockChannel = (data: LockDayDto) => request(`/api/wxpersonalchannel/lock`, 'POST', data) as Promise<Result<WxUser>>

export const checkOuted = (id: string) => request(`/api/wxpersonalchannel/checkOut/${id}`, 'GET') as Promise<Result<boolean>>

export const checkExpire = (id: string) => request(`/api/wxpersonalchannel/expire/${id}`, 'GET') as Promise<Result<boolean>>